package com.dzf.controller;


import com.dzf.entity.MyUser;
import com.dzf.entity.RespJson;
import com.dzf.service.CartService;
import com.dzf.util.SessionUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @author DZF
 * 购物车 后台
 */
@RestController
@RequestMapping("/api/adm/cart")
public class AdmCartController {
    @Autowired
    CartService cartService;

    @Autowired
    SessionUtil sessionUtil;

    /**
     * Tips：没有实际使用
     * 获取用户的购物车
     * @return 登录用户的购物车信息
     */
    @RequestMapping("/findAll")
    public RespJson findAll()
    {
        MyUser user = (MyUser) sessionUtil.getUser();
        if (user.getId()==0)
        {
            return RespJson.pack(401,"未登录！",null);
        }
        return RespJson.pack(200,"OK",cartService.findAll(user.getId()));
    }
}
